import request from '@/utils/request.js';

// 添加文章分类
export const articleCategoryAddService = (categoryData) => {
    return request.post('/category', categoryData, 
        {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        }
    );
}

// 获取文章分类
export const articleCategoryGetService = () => {
    return request.get('/category');
}

// 获取所有文章分类
export const articleCategoryListAllService = () => {
    const res = request.get('/category/all');
    return res;
}

// 修改类别名称
export const articleCategoryUpdateService = (updateCategoryData) => {
    console.log(updateCategoryData);
    return request.put('/category', updateCategoryData, {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
}

// 删除分类
export const articleCategoryDeleteService = (id) => {
    return request.delete('/category?id='+id);
}

// 文章列表查询
export const articleListService = (params)=>{
    return request.get('/article', {params: params});
}
// 新增文章
export const articleAddService = (articleData) => {
    return request.post('/article', articleData);
}
// 文章修改
export const articleUpdateService = (articleData) => {
    return request.put('/article', articleData);
}
// 文章删除
export const articleDeleteService = (id) => {
    return request.delete('/article?id='+id);
}
// 获取文章详情
export const articleDetailService = (id) => {
    return request.get('/article/detail?id='+id);
}

// 获取所有博客文章
export const articleListAllService = (params) => {
    return request.get('/article/all', {params: params});
}
